
# print("多进程计算")
from concurrent.futures import ProcessPoolExecutor,Future
from multiprocessing import Manager
import time
def cal(i,share_list:list):
    print(i)
    time.sleep(2)
    share_list.append(i**2)

if __name__ == '__main__':

    start = time.time()
    pool = ProcessPoolExecutor(3)
    manager = Manager()
    share_list = manager.list()
    for i in range(1,4):
        pool.submit(cal,i,share_list)
    pool.shutdown()
    print(share_list)
    end = time.time()
    print(end-start)


